<template>
  <div>
    <div>
      <!-- 保存和取消 -->
      <div class="context" style="margin-top:30px">
        <el-card shadow="hover">
          <el-row>
            <el-col :span="2" style=" margin-left:40px;">
              <el-button type="primary" @click="yes" title="保存" :icon="Edit">保存</el-button>
            </el-col>
            <el-col :span="4" style=" margin-left:30px;">
              <el-button type="primary" @click="no" title="取消" :icon="Delete">取消</el-button>
            </el-col>
          </el-row>
        </el-card>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter, useRoute } from "vue-router";
import { Edit, Delete } from "@element-plus/icons-vue";
import { defineEmits, ref } from 'vue'
//路由
const router = useRouter()
const route = useRoute()

//点击保存时,子组件向父组件传递消息,通知父组件进行保存并路由跳转
const emits = defineEmits(['yes'])

const props = defineProps({path:String})

//获得父组件传递路径
const go = ref()
go.value = props.path;

//定义保存与取消
function yes() {
  const data = "保存成功"
  emits('yes',data)
}
function no() {
  if (go.value != null && go.value != '') {
    router.push({ name: go.value });
  } else { 
     router.push({ name: "InquiryManagement" });
  }
  
}

</script>

<style scoped>
.context {
  margin-left: 10%;
  margin-right: 10%;
}
</style>







